home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / VSet2.0 / Src / dfi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-20  |  20.4 KB  |  564 lines  |  [TEXT/????]

  1. /*****************************************************************************
  2. *              NCSA HDF version 3.10r4
  3. *                June 25, 1991
  4. *
  5. * NCSA HDF Version 3.10r4 source code and documentation are in the public
  6. * domain.  Specifically, we give to the public domain all rights for future
  7. * licensing of the source code, all resale rights, and all publishing rights.
  8. * We ask, but do not require, that the following message be included in all
  9. * derived works:
  10. * Portions developed at the National Center for Supercomputing Applications at
  11. * the University of Illinois at Urbana-Champaign.
  12. * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  13. * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  14. * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  15. *****************************************************************************/
  16. #ifdef RCSID
  17. static char RcsId[] = "@(#)$Revision: 3.16 $"
  18. #endif
  19. /*
  20. $Header: /pita/work/HDF/dev/RCS/src/dfi.h,v 3.16 91/06/21 11:56:26 dilg beta $
  21. $Log:    dfi.h,v $
  22.  * Revision 3.16  91/06/21  11:56:26  dilg
  23.  * Removed malloc() from the #ifndef UNICOS at the end of the file.
  24.  * 
  25.  * Revision 3.15  91/05/21  12:25:57  dilg
  26.  * Changed #include <sys/fcntl.h> to #include <fcntl.h> in UNICOS section and
  27.  * put #ifndef UNICOS - #endif around redefinitions of strncpy(), strcpy(),
  28.  * malloc(), and memcpy() at end of file.  Needed because of change to 
  29.  * UNICOS 6.X.
  30.  * 
  31.  * Revision 3.14  90/10/02  14:16:49  clow
  32.  * fixed error in the define of DFmovmem in the MIPSEL segment
  33.  * 
  34.  * Revision 3.13  90/09/18  15:09:10  clow
  35.  * Added MIPSEL to 'list of approved machine types'
  36.  * 
  37.  * Revision 3.12  90/09/14  12:49:07  mfolk
  38.  * *** empty log message ***
  39.  * 
  40.  * Revision 3.11  90/08/30  14:51:59  mfolk
  41.  * Add DFMT_MIPSEL  0x4441 machine type and #ifdef section for MIPSEL.
  42.  * This should cover DEC3100 needs.
  43.  * 
  44.  * Revision 3.10  90/07/31  13:30:15  mfolk
  45.  * Added typedef double float64; to all machine types, so that this
  46.  * dfi.h would work with fp2hdf as changed by INEL.  (Mike Folk)
  47.  * 
  48.  * Revision 3.9  90/07/16  11:25:56  clow
  49.  * added #if's so that the compiler will complain if MACHINE is set wrongly.
  50.  * 
  51.  * Revision 3.8  90/07/05  17:00:08  clow
  52.  * Changed the lower value of DF_TBUF 512
  53.  * 
  54.  * Revision 3.7  90/06/28  09:41:26  clow
  55.  * Added segment for APOLLO machines
  56.  * 
  57.  * Revision 3.6  90/05/23  15:47:37  clow
  58.  * added MACRO "DF_OPENERR" to give uniform error open checking,
  59.  * especially for unbufferred I/O open
  60.  * 
  61.  * Revision 3.5  90/05/18  11:09:12  clow
  62.  * added missing #endif
  63.  * 
  64.  * Revision 3.4  90/05/17  17:06:00  clow
  65.  * added _fcd and _fcdtocp for LS FORTRAN so we don't have to go through
  66.  * an extra layer of Fortran stubs
  67.  * 
  68.  * Revision 3.4  90/05/17  16:04:14  clow
  69.  * added _fcd and _fcdtocp for LS FORTRAN so we don't have to go through
  70.  * an extra layer of Fortran stubs
  71.  * 
  72.  * Revision 3.3  90/05/14  23:15:45  clow
  73.  * added definition of MACRO "FCALLKEYW"
  74.  * 
  75. */
  76. /*-----------------------------------------------------------------------------
  77.  * File:    dfi.h
  78.  * Purpose: HDF internal header file
  79.  * Invokes: stdio.h, sys/file.h
  80.  * Contents: 
  81.  *  Compilation parameters
  82.  *  Machine-dependent definitions
  83.  *  Flexibility definitions: i/o buffering, dynamic memory, structure i/o
  84.  *  Size parameters
  85.  * Remarks: To port to a new system, only dfi.h and Makefile need be modified.
  86.  *          This file is included with user programs, but users do not see it.
  87.  *---------------------------------------------------------------------------*/
  88.  
  89.  
  90. #ifndef DF_MAGICK        /* avoid re-inclusion */
  91.  
  92. #define    DF_MAGICK    "\016\003\023\001" /* ^N^C^S^A */
  93.  
  94. #ifndef FILE
  95. #include <stdio.h>
  96. #endif /*FILE*/
  97.  
  98. /*--------------------------------------------------------------------------*/
  99. /*          Compilation Parameters for Flexibility and Portability          */
  100.  
  101. /* modify this line to allow for machine dependencies */
  102. #define    MAC
  103. /**IMPORTANT** this is now in the in the makefile */
  104.  
  105. #if !defined(SUN) && !defined(SUN386) && !defined(VMS) && !defined(ALLIANT)
  106. #if !defined(IRIS4) && !defined(MAC) && !defined(UNICOS) && !defined(MIPSEL)
  107. if there is error on this line, the MACHINE type is defined wrong!!!
  108. #endif
  109. #endif
  110.  
  111. /* modify this line for buffered/unbuffered i/o */
  112. #define    DF_BUFFIO
  113.  
  114. /* modify this line for dynamic/static memory allocation */
  115. #define    DF_DYNAMIC
  116.  
  117. /* modify this line if structures cannot be read/written as is */
  118. #undef    DF_STRUCTOK        /* leave it this way - hdfsh expects it */
  119.  
  120. /* Current version number */
  121. #define    DFVERSION   3.00
  122.  
  123. /*--------------------------------------------------------------------------*/
  124. /*                              MT/NT constants                             */
  125. /*      four MT nibbles represent int, float, double, uchar                 */
  126. #define    DFMT_SUN        0x1111
  127. #define    DFMT_ALLIANT    0x1111
  128. #define    DFMT_IRIS4      0x1111
  129. #define DFMT_APOLLO    0x1111
  130. #define    DFMT_UNICOS     0x3331
  131. #define    DFMT_CTSS       0x3331
  132. #define    DFMT_VAX        0x2221
  133. #define DFMT_MIPSEL     0x4441
  134. #define    DFMT_PC         0x4144    /* note byte swapping ??? */
  135.                 /* check this... */
  136. #define    DFMT_MAC        0x1111
  137. #define DFMT_SUN386    0x1444
  138.  
  139. #define    DFNT_VERSION    1    /* current version of NT info */
  140.  
  141. /* type info codes */
  142. #define    DFNT_UINT       1
  143. #define    DFNT_INT        2
  144. #define    DFNT_UCHAR      3
  145. #define    DFNT_CHAR       4
  146. #define    DFNT_FLOAT      5
  147. #define    DFNT_DOUBLE     6
  148.  
  149. /* class info codes for int */
  150. #define    DFNTI_MBO       1    /* Motorola byte order 2's compl */
  151. #define    DFNTI_VBO       2    /* Vax byte order 2's compl */
  152. #define    DFNTI_IBO       4    /* Intel byte order 2's compl */
  153.  
  154. /* class info codes for float */
  155. #define    DFNTF_IEEE      1    /* IEEE format */
  156. #define    DFNTF_VAX       2    /* Vax format */
  157. #define    DFNTF_CRAY      3    /* Cray format */
  158. #define    DFNTF_PC        4    /* PC floats - flipped IEEE */
  159.  
  160. /* class info codes for char */
  161. #define    DFNTC_BYTE      0    /* bitwise/numeric field */
  162. #define    DFNTC_ASCII     1    /* ASCII */
  163. #define    DFNTC_EBCDIC    5    /* EBCDIC */
  164.  
  165. /* array order */
  166. #define    DFO_FORTRAN     1    /* column major order */
  167. #define    DFO_C           2    /* row major order */
  168.  
  169. /*--------------------------------------------------------------------------*/
  170. /*                      Machine dependencies                                */
  171. #ifdef PC
  172. #ifndef O_RDONLY
  173. #include <fcntl.h>
  174. #define    L_INCR  1
  175. #endif /*O_RDONLY*/
  176. typedef    int int16;
  177. typedef    unsigned int uint16;
  178. typedef    long int int32;
  179. typedef    double float32;
  180. #define    DFmovmem(from, to, len) memcpy(to, from, len)
  181. #undef DF_STRUCTOK                  /* structure writing will not work on PC */
  182. #undef DF_BUFFIO                    /* unbuffered i/o is faster */
  183. long longswap();                    /* provided elsewhere */
  184.  
  185.     /* in the next 3 lines, p is recast so right number of bytes passed */
  186.     /* ### Note that all calls modify p.  Need to use temporary ptr */
  187. #define    UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  188. #define    INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  189. #define    INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  190.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  191. #define    UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  192. #define    INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  193. #define    INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  194.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  195. #define    DF_CREAT(name, prot) creat(name, prot)
  196. #define    DF_MT   DFMT_PC
  197. #endif /*PC*/
  198.  
  199.  
  200. #ifdef UNICOS
  201. #ifndef O_RDONLY
  202. #include <fcntl.h>              /* for unbuffered i/o stuff */
  203. #define    L_INCR  1
  204. #endif /*O_RDONLY*/
  205. typedef    int int16;
  206. typedef    int uint16;
  207. typedef    int int32;
  208. typedef    float float32;
  209. typedef double float64;
  210. #define    DFmovmem(from, to, len) memcpy(to, from, len)
  211. #undef DF_STRUCTOK          /* cannot directly read/write structures */
  212. #define    DF_CAPFNAMES            /* fortran names are in all caps */
  213. #define    UINT16READ(p, x)    { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  214. #define    INT16READ(p, x)     { x = (*p++)<<8; x |= (*p++) & 255; }
  215. #define    INT32READ(p, x)     { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  216.                                 x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  217. #define    UINT16WRITE(p, x)   { *p++ = (x>>8) & 255; *p++ = x & 255; }
  218. #define    INT16WRITE(p, x)    { *p++ = (x>>8) & 255; *p++ = x & 255; }
  219. #define    INT32WRITE(p, x)    { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;   \
  220.                                 *p++ = (x>>8) & 255; *p++ = x & 255; }
  221. #define    DF_CREAT(name, prot) creat(name, prot)
  222. #define    DF_MT   DFMT_UNICOS
  223. #endif /*UNICOS*/
  224.  
  225.  
  226. #ifdef SUN
  227. #if ! defined mc68010 && ! defined mc68020 && ! defined mc68030
  228. #undef DF_STRUCTOK
  229. #endif
  230. #include <sys/file.h>               /* for unbuffered i/o stuff */
  231. typedef    short int16;
  232. typedef    unsigned short uint16;
  233. typedef    long int32;
  234. typedef    float float32;
  235. typedef double float64;
  236. #define    DFmovmem(from, to, len) memcpy(to, from, len)
  237. #ifndef DF_STRUCTOK
  238. #define    UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  239. #define    INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  240. #define    INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  241.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  242. #define    UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  243. #define    INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  244. #define    INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  245.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  246. #endif /*DF_STRUCTOK*/
  247. #define    DF_CREAT(name, prot) creat(name, prot)
  248. #define    DF_MT   DFMT_SUN
  249. #endif /*SUN*/
  250.  
  251. #ifdef SUN386
  252. #undef DF_STRUCTOK
  253. #include <sys/file.h>               /* for unbuffered i/o stuff */
  254. typedef    short int16;
  255. typedef    unsigned short uint16;
  256. typedef    long int32;
  257. typedef    float float32;
  258. typedef double float64;
  259. #define    DFmovmem(from, to, len) memcpy(to, from, len)
  260. #ifndef DF_STRUCTOK
  261. #define    UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  262. #define    INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  263. #define    INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  264.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  265. #define    UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  266. #define    INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  267. #define    INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  268.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  269. #endif /*DF_STRUCTOK*/
  270. #define    DF_CREAT(name, prot) creat(name, prot)
  271. #define    DF_MT   DFMT_SUN386
  272. #endif /* SUN386 */
  273.  
  274. #ifdef ALLIANT
  275. #include <sys/file.h>               /* for unbuffered i/o stuff */
  276. typedef    short int16;
  277. typedef    unsigned short uint16;
  278. typedef    long int32;
  279. typedef    float float32;
  280. typedef double float64;
  281. #define    DFmovmem(from, to, len) bcopy(from, to, len)
  282. #ifndef DF_STRUCTOK
  283. #define    UINT16READ(p, x)    { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  284. #define    INT16READ(p, x)     { x = (*p++)<<8; x |= (*p++) & 255; }
  285. #define    INT32READ(p, x)     { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  286.                                 x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  287. #define    UINT16WRITE(p, x)   { *p++ = (x>>8) & 255; *p++ = x & 255; }
  288. #define    INT16WRITE(p, x)    { *p++ = (x>>8) & 255; *p++ = x & 255; }
  289. #define    INT32WRITE(p, x)    { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;   \
  290.                                 *p++ = (x>>8) & 255; *p++ = x & 255; }
  291. #endif /*DF_STRUCTOK*/
  292. #define    DF_CREAT(name, prot) creat(name, prot)
  293. #define    DF_MT   DFMT_ALLIANT
  294. #endif /*ALLIANT*/
  295.  
  296.  
  297. #ifdef IRIS4
  298. #undef DF_STRUCTOK
  299. #include <sys/types.h>
  300. #include <sys/file.h>               /* for unbuffered i/o stuff */
  301. typedef    short int16;
  302. typedef    unsigned short uint16;
  303. typedef    long int32;
  304. typedef    float float32;
  305. typedef double float64;
  306. #define    DFmovmem(from, to, len) bcopy(from, to, len)
  307. #ifndef DF_STRUCTOK
  308. #define    UINT16READ(p, x)    { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  309. #define INT16READ(p, x)     { x = (*p++)<<8; x |= (*p++) & 255; }
  310. #define INT32READ(p, x)     { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  311.                                 x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  312. #define UINT16WRITE(p, x)   { *p++ = (x>>8) & 255; *p++ = x & 255; }
  313. #define INT16WRITE(p, x)    { *p++ = (x>>8) & 255; *p++ = x & 255; }
  314. #define INT32WRITE(p, x)    { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;   \
  315.                                 *p++ = (x>>8) & 255; *p++ = x & 255; }
  316. #endif /*DF_STRUCTOK*/
  317. #define DF_CREAT(name, prot) creat(name, prot)
  318. #define DF_MT   DFMT_IRIS4
  319. #endif /*IRIS4*/
  320.  
  321.  
  322. #ifdef MIPSEL
  323. #undef DF_STRUCTOK
  324. #include <sys/types.h>
  325. #include <sys/file.h>               /* for unbuffered i/o stuff */
  326. typedef short int16;
  327. typedef unsigned short uint16;
  328. typedef long int32;
  329. typedef float float32;
  330. typedef double float64;
  331. #define DFmovmem(from, to, len) memcpy(to, from, len)
  332. #ifndef DF_STRUCTOK
  333. #define UINT16READ(p, x)    { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  334. #define INT16READ(p, x)     { x = (*p++)<<8; x |= (*p++) & 255; }
  335. #define INT32READ(p, x)     { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  336.                               x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  337. #define UINT16WRITE(p, x)   { *p++ = (x>>8) & 255; *p++ = x & 255; }
  338. #define INT16WRITE(p, x)    { *p++ = (x>>8) & 255; *p++ = x & 255; }
  339. #define INT32WRITE(p, x)    { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  340.                               *p++ = (x>>8) & 255; *p++ = x & 255; }
  341. #endif /*DF_STRUCTOK*/
  342. #define DF_CREAT(name, prot) creat(name, prot)
  343. #define DF_MT   DFMT_MIPSEL
  344. #endif /*MIPSEL*/
  345.  
  346.  
  347. #ifdef MAC
  348. #undef DF_BUFFIO        /* use unbuffered i/o */
  349. #include <memory.h>             /* malloc stuff for MPW 3.0 */
  350. #include <fcntl.h>              /* unbuffered IO stuff for MPW 3.0 */
  351. #ifdef THINK_C                  /* for LightSpeed C */
  352. #include <unix.h>
  353. #else /*THINK_C                   MPW, possibly others */
  354. #include <Files.h>              /* for unbuffered i/o stuff */
  355. #endif /*THINK_C*/
  356. #define    DF_CAPFNAMES            /* fortran names are in all caps */
  357. #define DF_DYNAMIC        /* use dynamic allocation */
  358. typedef short int16;
  359. typedef unsigned short uint16;
  360. typedef long int32;
  361. typedef float float32;
  362. typedef double float64;
  363. #ifdef THINK_C                   /* LightSpeed C does not have memcpy */
  364. #define DFmovmem(from, to, len) DFImemcopy(from, to, len)
  365. #else /*THINK_C*/
  366. #define DFmovmem(from, to, len) memcpy(to, from, len)
  367. #endif /*THINK_C*/
  368. #define malloc(x)   NewPtr((Size)   (x))    /* don't use malloc on the Mac */
  369. #define free(x)     DisposPtr((Ptr) (x))    /* don't use free on the Nac   */ 
  370. #undef DF_STRUCTOK
  371. #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  372. #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  373. #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  374.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  375. #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  376. #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  377. #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  378.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  379. #define DF_CREAT(name, prot) mopen(name, O_WRONLY|O_TRUNC|O_CREAT)
  380. #define DF_MT   DFMT_MAC
  381. #endif /*MAC*/
  382.  
  383. #ifdef VMS
  384. /*#undef DF_BUFFIO should be buff !!!!*/
  385.    /* use only unbuff i/o - buff doesn't work! */
  386. #ifndef DFopen                  /* avoid double includes */
  387. #include "dfivms.h"
  388. #endif /*DFopen*/
  389. #undef DF_STRUCTOK
  390. #define DF_CAPFNAMES            /* fortran names are in all caps */
  391. #include <file.h>               /* for unbuffered i/o stuff */
  392. typedef short int16;
  393. typedef unsigned short uint16;
  394. typedef long int32;
  395. typedef float float32;
  396. typedef double float64;
  397. #define DFmovmem(from, to, len) memcpy(to, from, len)
  398. #ifndef DF_STRUCTOK
  399. #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  400. #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  401. #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  402.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  403. #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  404. #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  405. #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  406.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  407. #endif /*DF_STRUCTOK*/
  408. #define DF_CREAT(name, prot) creat(name, prot)
  409. #define DF_MT   DFMT_VAX
  410. #endif /*VMS*/
  411.  
  412. #ifdef APOLLO
  413. #if ! defined mc68010 && ! defined mc68020 && ! defined mc68030
  414. #undef DF_STRUCTOK
  415. #endif
  416. #include <sys/file.h>               /* for unbuffered i/o stuff */
  417. #define int16 short
  418. #define uint16 unsigned short
  419. #define int32 long
  420. #define float32 float
  421. #define DFmovmem(from, to, len) memcpy(to, from, len)
  422. #ifndef DF_STRUCTOK
  423. #define UINT16READ(p, x) { x = ((*p++) & 255)<<8; x |= (*p++) & 255; }
  424. #define INT16READ(p, x) { x = (*p++)<<8; x |= (*p++) & 255; }
  425. #define INT32READ(p, x) { x = (*p++)<<24; x|=((*p++) & 255)<<16;    \
  426.             x|=((*p++) & 255)<<8; x|=(*p++) & 255; }
  427. #define UINT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  428. #define INT16WRITE(p, x) { *p++ = (x>>8) & 255; *p++ = x & 255; }
  429. #define INT32WRITE(p, x) { *p++ = (x>>24) & 255; *p++ = (x>>16) & 255;  \
  430.             *p++ = (x>>8) & 255; *p++ = x & 255; }
  431. #endif /*DF_STRUCTOK*/
  432. #define DF_CREAT(name, prot) creat(name, prot)
  433. #define DF_MT   DFMT_APOLLO
  434. #endif /*APOLLO*/
  435.  
  436.  
  437. /*--------------------------------------------------------------------------*/
  438. /*                      Flexibility parameters                              */
  439. #ifdef MAC            /* MAC specific file manager calls */
  440. #    define DF_OPEN(x,y) mopen(x,y)
  441. #    define DF_CLOSE(x) mclose(x)
  442. #    define DF_SEEK(x,y,z) mlseek(x,y,z)
  443. #    define DF_SKEND(x,y,z) mlseek(x,-1*y,z)
  444. #    define DF_TELL(x) mlseek(x,0L,1)
  445. #    define DF_READ(a,b,c,d) mread(d,a,b*c)
  446. #    define DF_WRITE(a,b,c,d) mwrite(d,a,b*c)
  447. #    define DF_FLUSH(a)            /* no need to flush */
  448. #    define DF_RDACCESS 0        /* dummy */
  449. #    define DF_WRACCESS 0        /* dummy */
  450. #    define DF_OPENERR(f)    ((f) == -1)
  451. #else /* !MAC */
  452. #ifdef DF_BUFFIO            /* set all calls to do buffered I/O */
  453. #define DF_OPEN(x,y) fopen(x,y)
  454. #define DF_CLOSE(x) fclose(x)
  455. #define DF_SEEK(x,y,z) fseek(x,y,z)
  456. #define DF_SKEND(x,y,z) fseek(x,y,z)
  457. #define DF_TELL(x) ftell(x)
  458. #define DF_READ(a,b,c,d) fread(a,b,c,d)
  459. #define DF_WRITE(a,b,c,d) fwrite(a,b,c,d)
  460. #define DF_FLUSH(a) fflush(a)
  461. #define DF_OPENERR(f)    (!(f))
  462. #ifdef PC
  463. #define DF_RDACCESS "rb"
  464. #define DF_WRACCESS "rb+"
  465. #else /*PC*/
  466. #define DF_RDACCESS "r"
  467. #define DF_WRACCESS "r+"
  468. #endif /*PC*/
  469.  
  470. #else /*DF_BUFFIO         unbuffered i/o */
  471. #define DF_OPEN(x,y) open(x,y)
  472. #define DF_CLOSE(x) close(x)
  473. #define DF_SEEK(x,y,z) lseek(x,y,z)
  474. #define DF_SKEND(x,y,z) lseek(x,-1*y,z)
  475. #define DF_TELL(x) lseek(x,0L,1)
  476. #define DF_READ(a,b,c,d) read(d,a,b*c)
  477. #define DF_WRITE(a,b,c,d) write(d,a,b*c)
  478. #define DF_OPENERR(f)    ((f) == -1)
  479. #define DF_FLUSH(a)                             /* no need to flush */
  480. #  ifdef PC
  481. #    define DF_RDACCESS O_RDONLY | O_RAW
  482. #    define DF_WRACCESS O_RDWR | O_RAW
  483. #  else 
  484. #    define DF_RDACCESS O_RDONLY
  485. #    define DF_WRACCESS O_RDWR
  486. #  endif /*!PC*/
  487. #endif /*DF_BUFFIO*/
  488. #endif /* !MAC */
  489.  
  490.  
  491.     /* if not allocating memory dynamically, need buffer for compression */
  492. #ifndef DF_DYNAMIC
  493. #define DF_TBUF
  494. #define DF_TBUFSZ    10000    /* buffer size */
  495. #endif /*DF_DYNAMIC*/
  496.  
  497.     /* if reading/writing structures not ok, need buffer for conversion */
  498. #ifndef DF_TBUF
  499. #ifndef DF_STRUCTOK
  500. #define DF_TBUF
  501. #define DF_TBUFSZ    512    /* buffer size can be smaller */
  502. #endif /*DF_STRUCTOK*/
  503. #endif /*DF_TBUF*/
  504.  
  505.     /* set buffer size */
  506. #ifdef DF_TBUF
  507. #ifndef DFMASTER
  508. extern
  509. #endif /*DFMASTER*/
  510.     char DFtbuf[DF_TBUFSZ];
  511. #endif /*DF_TBUF*/
  512.  
  513. /* VMS str descriptor conversion macro */
  514. #if defined(VMS)
  515. #   define _fcdtocp(desc) ((char *) *((char **) &desc[4]))
  516.     typedef char *_fcd;
  517. #else /* !VMS */
  518. #if defined(UNICOS)
  519. #   include <fortran.h>
  520. #else /* !VMS && !UNICOS */
  521. #if defined(MAC)        /* with LS_FORTRAN */
  522. #   define _fcdtocp(descp) (*((char**)(descp)))
  523.     typedef char** _fcd;
  524. #else /* !VMS && !UNICOS && !MAC */
  525. #   define _fcdtocp(desc) (desc)
  526.     typedef char *_fcd;
  527. #endif
  528. #endif /* !VMS && !UNICOS */
  529. #endif /* !VMS */
  530.  
  531. /* 
  532. MACRO FCALLKEYW for any special fortran-C stub keyword
  533.  
  534. MacIntosh MPW LS-fortran needs pascal since it can interface best with
  535. pascal functions
  536. */
  537. #if defined(MAC)        /* with LS FORTRAN */
  538. #   define FCALLKEYW    pascal
  539. #else /* !MAC */
  540. #   define FCALLKEYW    /*NONE*/
  541. #endif
  542.  
  543. /*--------------------------------------------------------------------------*/
  544. /*                          Size parameters                                 */
  545. #define DF_MAXDFS           32  /* How many DF's can be open at once */
  546. #define DF_DEFAULTDDS       16  /* How many DD's a file has by default */
  547. #define DF_MAXFNLEN         256 /* maximum length of filename parameters */
  548.  
  549. #ifndef MAC
  550. #ifndef UNICOS
  551. char *strncpy();
  552. char *strcpy();
  553. char *memcpy();
  554. #endif /* !UNICOS */
  555. char *malloc();
  556. #endif /* !MAC */
  557.  
  558. #endif /*DF_MAGICK*/
  559.